06. Async Scenarios

Async Scenarios

Async Scenarios Quiz

Here are the code snippets from the previous video:

// (A)

var data = get("data.json");
data.onload = function() {
  analyze(this.responseText);
};

// (B)

hugeArrayOfImages.forEach(function(i) {
  makeSepia(i);
});

// (C)

data.forEach(function(d) {
  var div = createDiv(d);
  body.appendChild(div);
});

// (D)

var worker = new Worker("worker.js");
worker.postMessage(data);
worker.onmessage = doSomething;

In which of the situations above (i.e., (A) through (D)) should you consider using Promises?

SOLUTION:
  • A
  • D

Solution

Async Scenarios Solution